package com.sky.mapper;

import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrdersMapper {
    /**
     * 获取订单id
     * @param id
     * @return
     */
    Orders getById(Long id);

    /**
     *
     *拒单
     * @param orders
     */

    void update(Orders orders);

    /**
     * 根据状态和下单时间查询订单
     * @param
     * @param
     */
    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> queryByStatusAndorderTime(Integer pendingPayment, LocalDateTime dateTime);

    void batchUpdate(List<Long> ids, Orders build);

    /**
     * 前一日未完成订单检测定时任务执行（超时未完成订单）
     */
    List<Orders> queryByStatusAndOrderTime(Integer pendingPayment, LocalDateTime dateTime);

    /**
     * 根据订单号查询当前用户的订单
     * @param outTradeNo
     * @param userId
     * @return
     */
    Orders getByNumberAndUserId(String outTradeNo, Long userId);

    /**
     *
     * @param paramMap
     * @return
     */
    List<Map> groupSumAmountByParams(Map paramMap);
}
